/* jshint esversion: 6 */
$(document).ready(function() {
    ifLoged();
    var sec = location.href.split('?')[1],
        c = decodeURIComponent(sec),
        params = JSON.parse(c); //得到原json数据
    var info = {
        cityName: params.position,
        checkTime: params.checkTime,
        select: ['行政区', '商圈', '地铁站', '车站', '景点'],
        keyword: params.keyword
    };
    var regionData, tradData, subwayData, stationData, spotData, startTime, endTime, cityList, priceRange,
        StarLevel,
        Level,
        brandSelected = [],
        brandSelect = '',
        overallRating = -1,
        priceRating = -1,
        distanceRating = 1, hotelSelectData;
    $('#keyword').val(info.keyword);
    $("#location").val(info.cityName);
    laydate.render({
        elem: '#calendar', //指定元素
        range: '至',
        format: 'yyyy-MM-dd',
        min: 0, //
        max: 30, //30天后
        value: params.time,
        done: function(date, fromDate, endDate) {
            var strS = fromDate.year + '/' + fromDate.month + '/' + fromDate.date,
                strE = endDate.year + '/' + endDate.month + '/' + endDate.date,
                dateStart = new Date(strS),
                dateEnd = new Date(strE);
            startTime = dateStart.getTime().toString();
            endTime = dateEnd.getTime().toString();
        }
    });
    var page = 1;
    fillsearchResult({
        cityName: info.cityName,
        limit: 8,
        page: page,
        checkTime: info.checkTime,
        hotelKeyword: info.keyword
    });
    $('.cityItem').on('mouseover', function() {
        $(this).addClass("active").siblings().removeClass("active");
        $(this).siblings().find('.cityMain').hide();
        $(this).find('.cityMain').show();
    });
    $.getJSON('data/city.json', function(data) {
        cityList = data.data;
        fillCityInfo(cityList);
    });
    // $.ajax(url + 'v1/city/list', {
    //         method: "get", // get请求
    //         dataType: 'json', // 进行json解析
    //         xhrFields: {
    //             withCredentials: true // 允许跨域名储存和访问cookie
    //         }
    //     })
    //     .done(function(data) { // 处理ajax成功的回调
    //         cityList = data.data;
    //         fillCityInfo(cityList);
    //     });
    $('#location').focus(function() {
        $('.citySelect').fadeIn(500);
        // $(".citylistitem").on('click', function() {
        //         if ($('#location').val() != this.dataset.name) {
        //             $('#location').val(this.dataset.name);
        //             info.cityName = this.dataset.name;
        //             regionData = '';
        //             tradData = '';
        //             subwayData = '';
        //             stationData = '';
        //             spotData = ''
        //         }
        //         // $(".citylistitem").on('click', function() {
        //         //     $('#location').val(this.dataset.name);
        //         // });
        //     })
        //判断页面是否第一次加载 是否存在城市列表数据缓存 如果没有 请求后台并获得数据缓存
    });
    $('#location').blur(function() {

        $('.citySelect').fadeOut(500);
    });
    setTimeout(() => {
        $(".citylistitem").on('click', function() {
            if ($('#location').val() != this.dataset.name) {
                $('#location').val(this.dataset.name);
                info.cityName = this.dataset.name;
                regionData = '';
                tradData = '';
                subwayData = '';
                stationData = '';
                spotData = '';
            }
            // $(".citylistitem").on('click', function() {
            //     $('#location').val(this.dataset.name);
            // });
        });
    }, 100);
    $('.location-type-item:eq(0)').on('click', function(e) {
        var $this = $(this),
            $listDiv = $('.areaListDiv'),
            $listLi = $('.areaListDiv li');
        $listDiv.show();
        $this.addClass("active");
        if (!regionData) {
            // $.getJSON('data/area.json', function(data) {
            //     var str = "";
            //     regionData = data.data.area;
            //     for (let i = 0; i < regionData.length; i++) {
            //         const e = regionData[i];
            //         str += ' <li class="areaItem fl" data-name="' + e + '">' + e + '</li>'
            //     }
            //     $('.areaList').html(str);
            // });
            ajaxXHR('get', url + 'v1/city/area', function(data) {
                var str = "";
                regionData = data.data.area;
                for (let i = 0; i < regionData.length; i++) {
                    const e = regionData[i];
                    str += ' <li class="areaItem fl">' + e + '</li>';
                }
                $('.areaList').html(str);
            }, {
                cityName: info.cityName
            });
        } else {
            $('.areaList').html('');
            var str = '';
            for (let i = 0; i < regionData.length; i++) {
                const e = regionData[i];
                str += ' <li class="areaItem fl" data-name="' + e + '">' + e + '</li>';
            }
            $('.areaList').append(str);
        }
    });
    $(".areaListDiv").on("click", 'li', function(e) {
        var $listDiv = $('.areaListDiv');
        $('.location-type-item:eq(0)').addClass("active").siblings().removeClass("active");
        $('#keyword').val(this.dataset.name);
        e.stopPropagation();
        $listDiv.fadeOut(500);
    });
    $('.location-type-item:eq(1)').on('click', function(e) {
        var $this = $(this),
            $listDiv = $('.tradListDiv');
        $listDiv.show();
        if (!tradData) {
            $.getJSON('data/tradinbeijing.json', function(data) {
                tradData = data.data.trad;
                $('.tradList').html('');
                var str = '';
                for (let i = 0; i < tradData.length; i++) {
                    const e = tradData[i];
                    str += ' <li class="tradItem fl" data-name="' + e + '">' + e + '</li>';
                }
                $('.tradList').append(str);
            });

        } else {
            $('.tradList').html('');
            var str = '';
            for (let i = 0; i < tradData.length; i++) {
                const e = tradData[i];
                str += ' <li class="tradItem fl" data-name="' + e + '">' + e + '</li>';
            }
            $('.tradList').append(str);
        }
    });
    $(".tradList").on("click", 'li', function(e) {
        var $this = $('.location-type-item:eq(1)'),
            $listDiv = $('.tradListDiv');
        $this.addClass("active").siblings().removeClass("active");
        $('#keyword').val(this.dataset.name);
        $listDiv.fadeOut(500);
        e.stopPropagation();
    });
    $('.location-type-item:eq(2)').on('click', function(e) {
        if (!$('#location').val()) {
            this.focus();
            $(this).val('请选择城市！');
            $('.modal-body').html('未选择城市！');
            $('.modal').modal('show');
            return;
        } else {
            var $this = $('.location-type-item:eq(2)'),
                $listDiv = $('.trainListDiv');
            $listDiv.show();
            if (!subwayData) {
                ajaxXHR('get', url + 'v1/city/subway/station', function(data) {
                    $('.trainList').html('');
                    var str = "";
                    subwayData = data.data.subway;
                    for (const key in subwayData) {
                        str += '<li class="trainItem clearfix fl">' + key + '<ul class="trainStationList pa clearfix none">';
                        const e = subwayData[key];
                        console.log(e);
                        for (let i = 0; i < e.length; i++) {
                            const ele = e[i];
                            str += '<li class="trainStationItem fl" data-name="' + ele + '">' + ele + '</li>';
                        }
                        str += '</ul></li>';

                    }
                    $('.trainList').append(str);
                }, {
                    cityName: info.cityName
                });
            } else {
                $('.trainList').html('');
                var str = '';
                for (var key in subwayData) {
                    str += '<li class="trainItem clearfix fl">' + key + '<ul class="trainStationList pa clearfix none">';
                    const e = subwayData[key];
                    for (let i = 0; i < e.length; i++) {
                        const ele = e[i];
                        str += '<li class="trainStationItem fl" data-name="' + ele + '">' + ele + '</li>'
                    }
                    // if (object.hasOwnProperty(key)) {
                    // }
                    str += '</ul></li>';
                }
                $('.trainList').append(str);
            }
            setTimeout(() => {
                //清除绑定事件
                $('.trainItem').unbind();
                $('.trainStationList').unbind();
                $('.trainItem').on('mouseover', function() {
                    //尝试进行链式调用
                    $(this).addClass("active").find('.trainStationList').show();
                    $(this).siblings().removeClass("active").find('.trainStationList').hide();
                });
                $('.trainItem').first().addClass("active");
                $('.trainStationList').first().show();
            }, 1000);
        }
    });
    //为弹出内容绑定事件
    $(".trainListDiv").on("click", 'li', function(e) {
        var $this = $('.location-type-item:eq(2)'),
            $listDiv = $('.trainListDiv');
        $this.addClass("active").siblings().removeClass("active");
        $('#keyword').val(this.dataset.name);
        $listDiv.fadeOut(500);
        e.stopPropagation();
        $('body').one('click', function(e) {
            $listDiv.fadeOut(500);
            e.stopPropagation();
            $('body').unbind();
        })
    });
    //为地区等关键字选择按钮绑定点击事件
    $('.location-type-item:eq(3)').on('click', function(e) {
        var $this = $(this),
            $trainList = $('.stationlist.train'),
            $buslist = $('.stationlist.bus'),
            $planeList = $('.stationlist.plane');

        $('.stationListDiv').show();
        if (!stationData) {
            ajaxXHR('get', url + 'v1/city/station', function(data) {
                stationData = data.data.station;
                $trainList.html('');
                var str = '';
                for (let i = 0; i < stationData.火车站.length; i++) {
                    const e = stationData.火车站[i];
                    console.log(e);
                    str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
                }
                $trainList.append(str);
                $buslist.html('');
                str = '';
                for (let i = 0; i < stationData.长途汽车站.length; i++) {
                    const e = stationData.长途汽车站[i];
                    str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
                }
                $buslist.append(str);
                $planeList.html('');
                str = '';
                for (let i = 0; i < stationData.飞机场.length; i++) {
                    const e = stationData.飞机场[i];
                    str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
                }
                $planeList.append(str);
            }, {
                cityName: info.cityName
            });
        } else {
            $trainList.html('');
            var str = '';
            for (let i = 0; i < stationData.火车站.length; i++) {
                const e = stationData.火车站[i];
                console.log(e);
                str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
            }
            $trainList.append(str);
            $buslist.html('');
            str = '';
            for (let i = 0; i < stationData.长途汽车站.length; i++) {
                const e = stationData.长途汽车站[i];
                str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
            }
            $buslist.append(str);
            $planeList.html('');
            str = '';
            for (let i = 0; i < stationData.飞机场.length; i++) {
                const e = stationData.飞机场[i];
                str += ' <li class="stationItem fl" data-name="' + e + '">' + e + '</li>';
            }
            $planeList.append(str);
        }
    });

    $(".stationListDiv").on("click", 'li', function(e) {
        var $this = $('.location-type-item:eq(3)'),
            $listDiv = $('.stationListDiv');
        $this.addClass("active").siblings().removeClass("active");
        $('#keyword').val(this.dataset.name);
        $listDiv.fadeOut(500);
        e.stopPropagation();
    });
    $('.location-type-item:eq(4)').on('click', function(e) {
        var $this = $(this),
            $spotList = $('.viewListDiv');
        $spotList.show();
        if (!spotData) {
            ajaxXHR('get', url + 'v1/city/view/spot', function(data) {
                spotData = data.data.viewSpot;
                $spotList.html('');
                var str = '';
                for (let i = 0; i < spotData.length; i++) {
                    const e = spotData[i];
                    console.log(e);
                    str += ' <li class="viewItem fl" data-name="' + e + '">' + e + '</li>'
                }
                $spotList.append(str);
            }, {
                cityName: info.cityName
            });
        } else {
            $spotList.html('');
            str = '';
            for (let i = 0; i < spotData.length; i++) {
                const e = spotData[i];
                str += ' <li class="viewItem fl" data-name="' + e + '">' + e + '</li>'
            }
            $spotList.append(str);
        }
        // $listLi.on('click', function() {
        //     $this.addClass("active").siblings().removeClass("active");
        //     $('#keyword').html(this.dataset.name);
        //     $listDiv.fadeOut(500);
        // });
    });
    var $listDiv = $('.viewListDiv');
    $listDiv.on("click", 'li', function(e) {
        var $this = $('.location-type-item:eq(3)');
        $this.addClass("active").siblings().removeClass("active");
        $('#keyword').val(this.dataset.name);
        $listDiv.fadeOut(500);
        e.stopPropagation();
    });
    // if (!subwayData) {
    //     $.getJSON('data/subway.json', function(data) {
    //         $('.trainList').html('');
    //         var str = "";
    //         subwayData = data.data.subway;
    //         console.log(subwayData);
    //         for (var key in subwayData) {
    //             console.log(key);
    //             const element = subwayData[key];
    //             console.log(element);
    //             // if (object.hasOwnProperty(key)) {
    //             // }
    //         }
    //     });
    $('.unlimited').on('click', function() {
        $(this).addClass("active").siblings().removeClass("active");
        $('#keyword').val('');
    });
    $('.price-type-item').on('click', function() {
        $(this).addClass('active').siblings().removeClass("active");
        priceRange = this.dataset.value;
    });
    $('.price-type-item-custom').on('click', ".searchByPrice", function() {
        var $priceEnd = $('#toPrice'),
            $priceFrom = $('#fromPrice'),
            priceFrom = parseInt($priceFrom.val()),
            priceEnd = parseInt($priceEnd.val());
        if (priceFrom && priceFrom && priceFrom < priceEnd) {
            $('.price-type-item-custom').addClass('active').siblings().removeClass("active");
            //发起一个ajax请求？
            priceRange = priceFrom + ',' + priceEnd;
        } else {
            if (!isNum(priceFrom)) {
                $priceFrom[0].focus();
                $priceFrom.val(1);
            } else if (!isNum(priceEnd) || priceFrom > priceEnd) {
                $priceEnd[0].focus();
                $priceEnd.val(priceFrom + 100);
                $('.price-type-item-custom').addClass('active').siblings().removeClass("active");
            }
        }
        priceRange = priceFrom + ',' + priceEnd;
    });
    $('.rateItem').on('click', function() {
        var $this = $(this);
        if ($this.hasClass("active")) {
            $this.removeClass("active");
            if (!$('.rateItem').hasClass("active") && !$('.spicalRateItem').hasClass("active")) {
                $this.siblings('.unlimited').addClass("active");
            }
        } else {
            $this.siblings('.unlimited').removeClass('active');
            $this.addClass("active").siblings().removeClass("active");
            // StarLevel.push(parseInt(this.dataset.value));
            StarLevel = parseInt(this.dataset.value);
            Level = "StarLevel";
        }
        console.log(StarLevel);
    });
    $('.spicalRateItem').on('click', function() {
        var $this = $(this);
        if ($this.hasClass("active")) {
            $this.removeClass("active");
            if (!$('.spicalRateItem').hasClass("active") && !$('.rateItem').hasClass("active")) {
                $this.siblings('.unlimited').addClass("active");
            }
        } else {
            $this.siblings('.unlimited').removeClass('active');
            $this.addClass("active").siblings().removeClass("active");
            Level = "specialLevel";
            StarLevel = this.dataset.value;
        }
    });
    $('.brandItem').on('click', function() {
        var $this = $(this);
        if ($this.hasClass("active")) {
            $this.removeClass("active");
            removeArrayItem(this.dataset.value, brandSelected);
            if (!$('.brandItem').hasClass("active")) {
                $this.siblings('.unlimited').addClass("active");
            }
        } else {
            $this.siblings('.unlimited').removeClass('active');
            $this.addClass("active");
            brandSelected.push(this.dataset.value);
            console.log(brandSelected);
            // brandSelected += ',' + this.dataset.value;
        }
    });
    $('header').on('click', function(e) {
        e.stopPropagation();
        console.log(e.target);
        var target = $(e.target);
        if (!target.is('.locationUnion *')) {
            $('.ListDiv').fadeOut(500);
        }
    });

    function countBrand() {
        brandSelect = brandSelected[0];
        for (let i = 1; i < brandSelected.length; i++) {
            const el = brandSelected[i];
            brandSelect += ',' + el;
        }
        console.log(brandSelect);
    }

    $('.searchingBar').on('click', function() {
        countBrand();
        console.log(Level);
        if (Level == "StarLevel") {
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                StarLevel: StarLevel,
                brand: brandSelect
            })
        } else if (Level == "specialLevel") {
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                specialLevel: StarLevel,
                brand: brandSelect
            })
        } else {
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                brand: brandSelect
            })
        }
    });
    $('.sortItem:eq(0)').on('click', function() {
        countBrand();
        var $this = $(this);
        if (!$this.hasClass("active")) {
            $this.addClass("active").siblings().removeClass("active");
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect
            });
        } else {

        }
    });
    $('.sortItem:eq(1)').on('click', function() {
        countBrand();
        var $this = $(this);
        if ($this.hasClass("active")) {
            if (overallRating == -1) {
                overallRating = 1;
                $this.find("i").addClass("reverse");
            } else if (overallRating == 1) {
                overallRating = -1;
                $this.find("i").removeClass("reverse");
            }
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect,
                overallRating: overallRating
            });
        } else {
            $this.find("i").removeClass("reverse");
            overallRating = -1;
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect,
                overallRating: overallRating,
            });
            $this.addClass("active").siblings().removeClass("active");
        }
    });
    $('.sortItem:eq(2)').on('click', function() {
        countBrand();
        var $this = $(this);
        if ($this.hasClass("active")) {
            if (priceRating == -1) {
                priceRating = 1;
                $this.find("i").addClass("reverse")
            } else if (priceRating == 1) {
                priceRating = -1;
                $this.find("i").removeClass("reverse")
            }
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect,
                price: priceRating
            })
        } else {
            $this.find("i").removeClass("reverse")
            priceRating = -1;
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect,
                price: priceRating,
            });
            $this.addClass("active").siblings().removeClass("active");
        }
    });
    $('.sortItem:eq(3)').on('click', function() {
        countBrand();
        var $this = $(this);
        $this.addClass("active").siblings().removeClass("active");
        if (!$this.hasClass("active")) {
            fillsearchResult({
                cityName: $('#location').val(),
                limit: 8,
                page: page,
                checkTime: startTime + ',' + endTime,
                hotelKeyword: $('#keyword').val(),
                priceRange: priceRange,
                starLevel: StarLevel,
                brand: brandSelect,
                distance: distanceRating,
            });
        }
    });

    function fillsearchResult(params) {
        fillData.init('.pageArray', url + 'v1/hotel/list', function(data) {
            var positionSet = [],
                centerLng, centerLat;
            hotelSelectData = data.data.hotelList;
            var str = '',
                starNumSet = [],
                location = {},
                i;
            for (i = 0; i < hotelSelectData.length; i++) {
                const e = hotelSelectData[i];
                // var imgsrc = url_file + e.picure[0];
                var imgsrc = "images/hotel1.jpg";
                str += '<li class="search-Item clearfix"><img src="' + imgsrc + '" alt="" class="hotel-cover fl"> <div class="item-info fl"><div class="infoLeft fl clearfix">'
                str += '<h2 class="inb hotelName">' + e.name + '</h2><div class="inb"><ul class="rating inb"><li class="rating-item fl active" title="很不好"></li><li class="rating-item fl active" title="很好"></li><li class="rating-item fl" title="一般"></li><li class="rating-item fl" title="好"></li><li class="rating-item fl" title="很好"></li></ul></div>'
                str += '<h3 class="inb f13 address">' + e.address + '<a id="showMap" class="showMap il ">-地图</a></h3>';
                str += '</div><div class="infoMiddle fl "><span class="commonRate">' + e.overall_rating + '</span><span class="f13">/5分</span><p class="commentTimes">' + e.comment_num + '次点评</p></div>'
                str += '<div class="infoRight fl "><span class="hotelPrice"> ￥' + e.price + '</span><span>起</span><a href="hotelDetail.html?id=' + e._id + '"><div class="viewDetail">查看详情</div></a></div></div></li>';
                const b = i + 1;
                location.name = b + '.' + e.name;
                location.location = new BMap.Point(e.location.lng, e.location.lat);
                positionSet.push(location);
                location = {};
                starNumSet.push(e.star_level);
            };

            $('.searchResult').html(str);
            $('#searchResultMap').html('');
            var mainmap = new BMap.Map("searchResultMap"); // 创建Map实例
            mainmap.centerAndZoom(new BMap.Point(positionSet[0].location.lng, positionSet[0].location.lat), 15); // 初始化地图,设置中心点坐标和地图级别
            //添加地图类型控件
            mainmap.addControl(new BMap.MapTypeControl({
                mapTypes: [
                    BMAP_NORMAL_MAP
                ]
            }));
            mainmap.setCurrentCity("北京"); // 设置地图显示的城市 此项是必须设置的
            mainmap.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
            mainmap.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT }));
            positionSet.forEach(el => {
                const marker = new BMap.Marker(el.location) // 创建标注点
                mainmap.addOverlay(marker) // 向地图添加标注点
                marker.setLabel(new BMap.Label(el.name, {
                    offset: new BMap.Size(20)
                })); // 向标注点添加标注文本
            });
            for (let x = 0; x < i; x++) {
                $('.rating').eq(x).rating({ num: starNumSet[x] });
            }

        }, params, {
            ifPaging: true,
        });
        // $.getJSON('data/selectData.json', function(data) {
        //     hotelSelectData = data.data.hotelList;
        //     var str = '',
        //         starNumSet = [],
        //         location = {},
        //         i;
        //     for (i = 0; i < hotelSelectData.length; i++) {

        //         const e = hotelSelectData[i];
        //         if (i == 0) {
        //             console.log(e.location.lng);
        //             centerLng = e.location.lng;
        //             centerLat = e.location.lat;
        //         }
        //         // var imgsrc = url_file + e.picure[0];
        //         var imgsrc = "images/hotel1.jpg";
        //         str += '<li class="search-Item clearfix"><img src="' + imgsrc + '" alt="" class="hotel-cover fl"> <div class="item-info fl"><div class="infoLeft fl clearfix">'
        //         str += '<h2 class="inb hotelName">' + e.name + '</h2><div class="inb"><ul class="rating inb"><li class="rating-item fl active" title="很不好"></li><li class="rating-item fl active" title="很好"></li><li class="rating-item fl" title="一般"></li><li class="rating-item fl" title="好"></li><li class="rating-item fl" title="很好"></li></ul></div>'
        //         str += '<h3 class="inb f13 address">' + e.address + '<a id="showMap" class="showMap il ">-地图</a></h3>';
        //         str += '</div><div class="infoMiddle fl "><span class="commonRate">' + e.overall_rating + '</span><span class="f13">/5分</span><p class="commentTimes">' + e.comment_num + '次点评</p></div>'
        //         str += '<div class="infoRight fl "><span class="hotelPrice"> ￥' + e.price + '</span><span>起</span><a href="hotelDetail?id=' + e._id + '"><div class="viewDetail">查看详情</div></a></div></div></li>';
        //         location.name = i + '.' + e.name;
        //         location.location = new BMap.Point(e.location.lng, e.location.lat);
        //         positionSet.push(location);
        //         location = {};
        //         starNumSet.push(e.star_level);
        //     };

        //     $('.searchResult').html(str);
        //     positionSet.forEach(el => {
        //         const marker = new BMap.Marker(el.location) // 创建标注点
        //         mainmap.addOverlay(marker) // 向地图添加标注点
        //         marker.setLabel(new BMap.Label(el.name, {
        //                 offset: new BMap.Size(20)
        //             })) // 向标注点添加标注文本
        //     });
        //     for (let x = 0; x < i; x++) {
        //         $('.rating').eq(x).rating({ num: starNumSet[x] });
        //     };

        // });
    }
})